import java.util.ArrayList;

/*
 * Class Statistics.
 * Stores student statistics.
 */

public class Statistics {
	
	private int decksAttempted;
	private int decksCompleted;
	private int decksAborted;
	private int questionsAnswered;
	private int questionsSkipped;
	private int questionsCorrect;
	private int questionsIncorrect;
	private ArrayList<Double> timerScores = new ArrayList<Double>();
	private ArrayList<Double> completionScores = new ArrayList<Double>();
	private double highestTimer;
	private double highestCompletion;
	
	public Statistics() {
		this(0, 0, 0, 0, 0, 0, 0, 0, 0);
	}
	
	public Statistics(int decksAttempted, int decksCompleted, int decksAborted,
			int questionsAnswered, int questionsSkipped, int questionsCorrect,
			int questionsIncorrect, double highestTimer, double highestCompletion) {
		this.decksAttempted = decksAttempted;
		this.decksCompleted = decksCompleted;
		this.decksAborted = decksAborted;
		this.questionsAnswered = questionsAnswered;
		this.questionsSkipped = questionsSkipped;
		this.questionsCorrect = questionsCorrect;
		this.questionsIncorrect = questionsIncorrect;
		this.highestTimer = highestTimer;
		this.highestCompletion = highestCompletion;
	}

	public int getDecksAttempted() {
		return decksAttempted;
	}
	
	public void incrementDecksAttempted() {
		decksAttempted++;
	}
	
	public int getDecksCompleted() {
		return decksCompleted;
	}
	
	public void incrementDecksCompleted(double score, boolean timer) {
		if (timer) {
			timerScores.add(score);
			if (score > highestTimer) highestTimer = score;
		} else {
			completionScores.add(score);
			if (score > highestCompletion) highestCompletion = score;
		}
		decksCompleted++;
	}
	
	public int getDecksAborted() {
		return decksAborted;
	}
	
	public void incrementDecksAborted() {
		decksAborted++;
	}
	
	public int getQuestionsAnswered() {
		return questionsAnswered;
	}
	
	public void incrementQuestionsAnswered() {
		questionsAnswered++;
	}
	
	public int getQuestionsSkipped() {
		return questionsSkipped;
	}
	
	public void incrementQuestionsSkipped() {
		questionsSkipped++;
	}
	
	public int getQuestionsCorrect() {
		return questionsCorrect;
	}
	
	public void incrementQuestionsCorrect() {
		questionsCorrect++;
	}
	
	public int getQuestionsIncorrect() {
		return questionsIncorrect;
	}
	
	public void incrementQuestionsIncorrect() {
		questionsIncorrect++;
	}
	
	public double getAverageTimer() {
		return average(timerScores);
	}
	
	public double getHighestTimer() {
		return highestTimer;
	}
	
	public double getAverageCompletion() {
		return average(completionScores);
	}
	
	public double getHighestCompletion() {
		return highestCompletion;
	}
	
	private double average(ArrayList<Double> scores) {
		double sum = 0;
		for (int i = 0; i < scores.size(); i++)
			sum += scores.get(i);
		return sum / scores.size();
	}
}
